﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using BAL.Entities;
using DAL.LogicComponents;
using System.Data;

namespace BAL.Components
{
    public class clsProductBAL
    {
        #region --- Product List by User
        public static DataTable doProductSelectList()
        {
            try
            {
                return clsProductDAL.queryselectProductList();
            }
            catch
            {
                throw;
            }
        }

        #endregion

        #region --- Product List
        public static DataTable doProductList()
        {
            try
            {
                return clsProductDAL.queryselectProductList();
            }
            catch
            {
                throw;
            }
        }

        #endregion

        #region --- Favorite List
        public static DataTable doGetCartOrFavoriteList(clsProduct obj)
        {
            try
            {
                return clsProductDAL.querySelectCartOrFavoriteList(obj);
            }
            catch
            {
                throw;
            }
        }

        #endregion

        #region --- Select Product By ID
        public static DataTable doProductSelectID(clsProduct obj)
        {
            try
            {
                return clsProductDAL.queryselectProduct(obj);
            }
            catch
            {
                throw;
            }
        }

        #endregion

        #region --- Check Product By User
        public static bool doCheckProduct(clsProduct product, clsUser user)
        {
            try
            {
                int userid = Convert.ToInt32(clsProductDAL.queryCheckProductByUser(product).Rows[0]["colUserID"]);
                return userid.Equals(user.UserID);
            }
            catch
            {
                throw;
            }
        }

        #endregion

        #region --- Select Producer
        public static DataTable doGetProducerList()
        {
            try
            {
                return clsProducerDAL.querySelectProducerList();
            }
            catch
            {
                throw;
            }
        }

        #endregion

        #region --- Product List by User
        public static DataTable doProductListByUser(clsUser obj)
        {
            try
            {
                return clsProductDAL.queryGetProductListByUser(obj);
            }
            catch
            {
                throw;
            }
        }

        #endregion

        #region --- Add Product by User
        public static bool doAddNewProduct(clsProduct obj)
        {
            try
            {
                return clsProductDAL.queryAddNewProduct(obj);
            }
            catch
            {
                throw;
            }
        }

        #endregion

        #region --- Update Product by User
        public static bool doUpdateProduct(clsProduct obj)
        {
            try
            {
                return clsProductDAL.queryUpdateProductByUser(obj);
            }
            catch
            {
                throw;
            }
        }

        #endregion

        #region --- Delete Product by User
        public static bool doDeleteProduct(clsProduct obj)
        {
            try
            {
                return clsProductDAL.queryDeleteProductByUser(obj) ;
            }
            catch
            {
                throw;
            }
        }

        #endregion

    }
}